home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / elk-2_0.lha / elk-2.0 / examples / scheme / cc < prev    next >
Encoding:
Text File  |  1989-02-17  |  474 b   |  31 lines

  1. ;;; -*-Scheme-*-
  2.  
  3. (define acc)
  4. (define bcc)
  5. (define n 5)
  6.  
  7. (define (a)
  8.   (if (not (= 0 (call-with-current-continuation
  9.          (lambda (cc)
  10.            (set! acc cc) 0))))
  11.       (if (> n 0)
  12.       (begin
  13.         (set! n (- n 1))
  14.         (display "resume b") (newline)
  15.         (bcc 1))
  16.       #v)
  17.       acc))
  18.  
  19. (define (b)
  20.   (if (not (= 0 (call-with-current-continuation
  21.          (lambda (cc)
  22.            (set! bcc cc) 0))))
  23.       (begin
  24.         (display "resume a") (newline)
  25.         (acc 1)))
  26.   bcc)
  27.  
  28. (a)
  29. (b)
  30. (acc 1)
  31.